<?php

include '../../../configuration.php';

$category = $_POST['category'];
$faculty_ids = array();
$i = 0;
while ( $i < 3 ) {
	if($_POST["ch".$i] != null) $faculty_ids[] = $_POST["ch".$i];
	$i++;
}
$faculty_id;
for ($i = 0; $i < count($faculty_ids); $i++) {
	if ($i == (count($faculty_ids)-1)) $faculty_id .= $faculty_ids[$i];
	else $faculty_id .= $faculty_ids[$i].",";
}

mysql_query("INSERT INTO `categories` (cat_id, cat_title, faculty_ids) VALUES (null, '$category', '$faculty_id')");

header("Location: insert_category.php");

?>